package Huihu.src.chat;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

public class Udpsender {
    public static void main(String[] args) throws Exception {
        DatagramSocket socket=new DatagramSocket(8888);
            //发送数据
        BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String str = bufferedReader.readLine();
            InetAddress inetAddress = InetAddress.getByName("127.0.0.1");
            DatagramPacket packet = new DatagramPacket(str.getBytes(), 0, str.getBytes().length, inetAddress, 6666);
            socket.send(packet);
            if (str.equals("byte")) {
                break;
            }
        }
    }
}
